
import MemberAPI from '../api/member.js';

export const Member={
   state:{
      memberlist:[],
      member_total_count:0,
      memberinfo:[],
      qy_code:''
   },
   mutations:{
      setMemberList(state,list){
          state.memberlist=list;
      },
      setMemberTotalCount(state,total_count){
          state.member_total_count=total_count;
      },
      setMemberInfo(state,info){
          state.memberinfo=info;
      },
      setQyCode(state,qy_code){
          state.qy_code=qy_code;
      }
   },
   actions:{
      loadMemberList(context,data){
          MemberAPI.getMemberList(data).then(function(response){
              if(response.data.code==1){
                  context.commit('setMemberList',response.data.data.list);
                  context.commit('setMemberTotalCount',response.data.data.total_count);
              }
          })
      },
      //获取详情
      loadMemberInfo(context,data){
          MemberAPI.getMemberInfo(data).then(function(response){
              if(response.data.code==1){
                  context.commit('setMemberInfo',response.data.info);
              }
          })
      },
   },
   getters:{
      getMemberList:state =>{
         return state.memberlist
      },
      getMemberTotalCount: state =>{
         return state.member_total_count
      },
      getMemberInfo:state => {
          return state.memberinfo;
      },
      getQyCode:state => {
          return state.qy_code;
      }
   }
}
